function DruidG1zStar3()

	-- TauntTrainer()

	if ccrValidTarget() and not IsMounted() and GetShapeshiftForm() ~= 1 then CastShapeshiftForm(1) return end
	if ccrValidTarget() and not ccrPIIC() and SIR("Enrage") then ccrCast("Enrage") return end

	if ccrValidTarget() and ccrPIIC() then
		
		if useCDS and SIR("Berserking") then ccrCast("Berserking") end
		if useCDS and SIR("Lifeblood") then ccrCast("Lifeblood") end
		
		if SIR("Barkskin") then ccrCast("Barkskin") end
		
		if ccRS.Manual_AoE and ccrTargetCount(8) > 1 then
			if SCA("Thrash") and not ccrTargetHasDebuff("Thrash") then ccrCastAttack("Thrash") return end
			if SCA("Mangle") then ccrCastAttack("Mangle") return end
			if SCA("Swipe") then ccrCastAttack("Swipe") return end
		end
		
		if (ccrTargetHasDebuffRemaining("Weakened Blows", 3) or not ccrTargetHasDebuff("Weakened Blows", any)) and SCA("Thrash") then ccrCastAttack("Thrash") return end
		if ccrPHB("Tooth and Claw") and ccrRage() >= 90 and SCA("Maul") then ccrCastAttack("Maul") return end
		if SCA("Lacerate") and (ccrTargetHasDebuffRemaining("Lacerate",3) or (not ccrTargetHasDebuffStacks("Lacerate", 3) and not ccrTargetHasDebuffRemaining("Weakened Blows", 3)) or ccrPHB("Berserk")) then ccrCastAttack("Lacerate") return end
		if not ccrTargetHasDebuffStacks("Weakened Armor", 3, any) and SIR("Faerie Fire") then ccrCast("Faerie Fire") return end
		if ccrTargetHasDebuffRemaining("Thrash", 3) and ccrPHB("Berserk") and SCA("Thrash") then ccrCastAttack("Thrash") return end
		if SCA("Mangle") then ccrCastAttack("Mangle") return end
		if SpellCDDuration("Mangle") > 0 and SpellCDDuration("Mangle") <= 0.5 then return end
		if SIR("Cenarion Ward") then ccrCast("Cenarion Ward", "player") return end
		if ccrTargetHasDebuffRemaining("Lacerate", 3) or not ccrTargetHasDebuffStacks("Lacerate", 3) and SCA("Lacerate") then ccrCastAttack("Lacerate") return end
		if SCA("Thrash") and ccrTargetHasDebuffRemaining("Thrash", 2) then ccrCastAttack("Thrash") return end
		if SCA("Lacerate") then ccrCastAttack("Lacerate") return end
		if SIR("Faerie Fire") and not ccrTargetHasDebuffRemaining("Thrash", 6) then ccrCast("Faerie Fire") return end
		if SCA("Thrash") then ccrCastAttack("Thrash") return end
	end
end

function DruidG1zStar2()

	--if not isAoE then AoEToggle() end

	if not ripframe then ripframe = CreateFrame("Frame", "ripframe", UIParent) end
	if ripframe:IsEventRegistered("COMBAT_LOG_EVENT") ~= 1 then ripframe:RegisterEvent("COMBAT_LOG_EVENT") end
	if not spellframe then
		spellframe = CreateFrame("GameTooltip", "spellframe", UIParent, "GameTooltipTemplate")
		spellframe:SetOwner(UIParent, "ANCHOR_NONE")
	end
	if not debuffframe then
		debuffframe = CreateFrame("GameTooltip", "debuffframe", UIParent, "GameTooltipTemplate")
		debuffframe:SetOwner(UIParent, "ANCHOR_NONE")
	end

	if ccrValidTarget() then
		if not _G[UnitGUID("target").."_ripcurdmg"] then _G[UnitGUID("target").."_ripcurdmg"] = 0 end
		if not _G[UnitGUID("target").."_rakecurdmg"] then _G[UnitGUID("target").."_rakecurdmg"] = 0 end
	end

	if ccrValidTarget() and not ccrPIIC() and GetShapeshiftForm() ~= 3 then CastShapeshiftForm(3) return end
	if ccrValidTarget() and not ccrPIIC() and GetShapeshiftForm() == 3 and not ccrPHB("Savage Roar") then ccrCast("Savage Roar") return end
	if ccrPIIC() and ccrValidTarget() then

		if GetShapeshiftForm() ~= 3 then CastShapeshiftForm(3) return end

		local _, energyregen = GetPowerRegen()

		if ccRS.Manual_AoE and ccrPlayerCount(8) >= 5 then
			if SCA("Faerie Fire") and not ccrTargetHasDebuffStacks("Weakened Armor", 3, any) then ccrCastAttack("Faerie Fire") return end
			if SIR("Faerie Fire") then FaerieFireCheck() end
			if not ccrPHB("Savage Roar") or (ccrPHBR("Savage Roar", 3) and ccrPoints() > 0) then ccrCast("Savage Roar") return end
			if not ccrPHB("Omen of Clarity") and ccrEnergy() <= 35 and SIR("Tiger's Fury") then ccrCast("Tiger's Fury") return end
			if ccrPHB("Tiger's Fury") and useCDS and SIR("Lifeblood") then ccrCast("Lifeblood") return end
			if ccrPHB("Tiger's Fury") and useCDS and SIR("Berserking") then ccrCast("Berserking") return end
			if ccrPHB("Tiger's Fury") and useCDS and SIR("Berserk") then ccrCast("Berserk") return end
			if ccrPHB("Rune of Re-Origination") and not onCD("Thrash") and ccrInRange("Thrash","target") and select(2, IsUsableSpell("Thrash")) then return end
			if SCA("Thrash") then ccrCastAttack("Thrash") return end
			if SCA("Thrash") and ((ccrTargetHasDebuffRemaining("Thrash", 3) or not ccrTargetHasDebuff("Thrash")) or (ccrPHB("Tiger's Fury") and ccrTargetHasDebuffRemaining("Thrash", 9))) then ccrCastAttack("Thrash") return end
			if ccrPoints() == 5 and ccrPHBR("Savage Roar", 9) then ccrCast("Savage Roar") return end
			if SCA("Rip") and ccrPoints() == 5 then ccrCastAttack("Rip") return end
			if SCA("Swipe") and ccrPHBR("Savage Roar", 5) then ccrCastAttack("Swipe") return end
			if SCA("Swipe") and (ccrPHB("Berserk" or ccrPHB("Tiger's Fury"))) then ccrCastAttack("Swipe") return end
			if SCA("Swipe") and SpellCDDuration("Tiger's Fury") > 0 and SpellCDDuration("Tiger's Fury") < 3 then ccrCastAttack("Swipe") return end
			if SCA("Swipe") and ccrPHB("Omen of Clarity") then ccrCastAttack("Swipe") return end
			if SCA("Swipe") and (((100 - UnitPower("player")) / energyregen) <= 1.0) then ccrCastAttack("Swipe") return end
		end

		if SCA("Ferocious Bite") and ccrTargetHasDebuff("Rip") and ccrTargetHasDebuffRemaining("Rip", 3) and ccrTargetHealth() <= 25 then ccrCastAttack("Ferocious Bite") return end
		if SCA("Faerie Fire") and not ccrTargetHasDebuffStacks("Weakened Armor", 3, any) then ccrCastAttack("Faerie Fire") return end
		if ccrPlayerHasTalent("Dream of Cenarius") and ccrPHB("Predatory Swiftness") and not ccrPHB("Dream of Cenarius") and (ccrPHBR("Predatory Swiftness", 1.5) or ccrPoints() >= 4) then ccrCast("Healing Touch", "player") return end
		if SIR("Savage Roar") and (ccrPHBR("Savage Roar", 3) or not ccrPHB("Savage Roar")) then ccrCast("Savage Roar") return end
		if SIR("Tiger's Fury") and ccrEnergy() <= 35 and not ccrPHB("Omen of Clarity") then ccrCast("Tiger's Fury") return end
		if useCDS and ccrPHB("Tiger's Fury") and SIR("Berserk") then ccrCast("Berserk") return end
		if useCDS and ccrPHB("Tiger's Fury") and SIR("Lifeblood") then ccrCast("Lifeblood") return end
		if useCDS and ccrPHB("Tiger's Fury") and SIR("Berserking") then ccrCast("Berserking") return end
		if SCA("Rip") and ccrPoints() == 5 and ccrTargetHealth() <= 25 and ((currip() / 1.15) > _G[UnitGUID("target").."_ripcurdmg"]) then ccrCastAttack("Rip") return end
		if SCA("Ferocious Bite") and ccrPoints() == 5 and ccrTargetHealth() <= 25 and ccrTargetHasDebuff("Rip") then ccrCastAttack("Ferocious Bite") return end
		if SCA("Rip") and ccrPoints() == 5 and (ccrTargetHasDebuffRemaining("Rip", 2) or not ccrTargetHasDebuff("Rip")) then ccrCastAttack("Rip") return end
		if SCA("Thrash") and ccrPHB("Omen of Clarity") and (ccrTargetHasDebuffRemaining("Thrash", 3) or not ccrTargetHasDebuff("Thrash")) then ccrCastAttack("Thrash") return end
		-- add check
		-- feralDotNearbyTarget()
		if SCA("Rake") and ((ccrTargetHasBuffRemaining("Rake", 3) or not ccrTargetHasDebuff("Rake")) or (currake() > rakecurdmg())) then ccrCastAttack("Rake") return end
		-- add check
		if (ccrTargetHasDebuffRemaining("Thrash", 3) or not ccrTargetHasDebuff("Thrash")) and (ccrPHB("Berserk") or ccrPoints() == 5 or (not ccrPHBR("Savage Roar",12) and not ccrTargetHasDebuffRemaining("Rip",8))) then
			if select(2, IsUsableSpell("Thrash")) and ccrInRange("Thrash","target") then return end
		end
		if SCA("Thrash") and ((ccrTargetHasDebuffRemaining("Thrash", 3) or not ccrTargetHasDebuff("Thrash")) and (ccrPHB("Berserk") or ccrPoints() == 5 or (not ccrPHBR("Savage Roar", 12) and not ccrTargetHasDebuffRemaining("Rip", 8)))) then ccrCastAttack("Thrash") return end
		if ccrPoints() == 5 and not (((100-UnitPower("player"))/energyregen) <= 1 or (ccrPHB("Berserk") and ccrEnergy() >= 25)) and ccrTargetHasDebuff("Rip") then return end
		-- if ccrPoints() == 5 and (not (ccrPHB("Berserk") and ccrEnergy() >= 25) or not ((100-UnitPower("player"))/energyregen) <= 1) and ccrTargetHasDebuff("Rip") then return end
		if SCA("Ferocious Bite") and ccrPoints() == 5 and ccrTargetHasDebuff("Rip") then ccrCastAttack("Ferocious Bite") return end
		if ccrPHB("Omen of Clarity") then
			if SCA("Ravage") and ccrPHB("Prowl") and ccrPlayerIsBehindTarget() then ccrCastAttack("Ravage") return end
			if SCA("Rake") and ((currake()*(raketicksremaining()+1)-rakecurdmg()*raketicksremaining()) > mangledmg()) then ccrCastAttack("Rake") return end
			if SCA("Shred") and ((ccrPlayerIsBehindTarget() and (ccrPHB("Omen of Clarity") or energyregen >= 15)) or ccrPHB("Berserk")) then ccrCastAttack("Shred") return end
			if SCA("Mangle") then ccrCastAttack("Mangle") return end
		end
		if (ccrPoints() < 5 and ccrTargetHasDebuffRemaining("Rip", 3)) or (ccrPoints() == 0 and ccrPHBR("Savage Roar", 2)) then 
			if SCA("Ravage") and ccrPHB("Prowl") and ccrPlayerIsBehindTarget() then ccrCastAttack("Ravage") return end
			if SCA("Rake") and ((currake()*(raketicksremaining()+1)-rakecurdmg()*raketicksremaining()) > mangledmg()) then ccrCastAttack("Rake") return end
			if SCA("Shred") and ((ccrPlayerIsBehindTarget() and (ccrPHB("Omen of Clarity") or energyregen >= 15)) or ccrPHB("Berserk")) then ccrCastAttack("Shred") return end
			if SCA("Mangle") then ccrCastAttack("Mangle") return end			
		end
		if ccrPHB("Berserk") or ccrPHB("Tiger's Fury") then
			if SCA("Ravage") and ccrPHB("Prowl") and ccrPlayerIsBehindTarget() then ccrCastAttack("Ravage") return end
			if SCA("Rake") and ((currake()*(raketicksremaining()+1)-rakecurdmg()*raketicksremaining()) > mangledmg()) then ccrCastAttack("Rake") return end
			if SCA("Shred") and ((ccrPlayerIsBehindTarget() and (ccrPHB("Omen of Clarity") or energyregen >= 15)) or ccrPHB("Berserk")) then ccrCastAttack("Shred") return end
			if SCA("Mangle") then ccrCastAttack("Mangle") return end
		end
		if SpellCDDuration("Tiger's Fury") <= 3 then
			if SCA("Ravage") and ccrPHB("Prowl") and ccrPlayerIsBehindTarget() then ccrCastAttack("Ravage") return end
			if SCA("Rake") and ((currake()*(raketicksremaining()+1)-rakecurdmg()*raketicksremaining()) > mangledmg()) then ccrCastAttack("Rake") return end
			if SCA("Shred") and ((ccrPlayerIsBehindTarget() and (ccrPHB("Omen of Clarity") or energyregen >= 15)) or ccrPHB("Berserk")) then ccrCastAttack("Shred") return end
			if SCA("Mangle") then ccrCastAttack("Mangle") return end
		end
		if ((100 - UnitPower("player")) / energyregen) <= 1.0 then
			if SCA("Ravage") and ccrPHB("Prowl") and ccrPlayerIsBehindTarget() then ccrCastAttack("Ravage") return end
			if SCA("Rake") and ((currake()*(raketicksremaining()+1)-rakecurdmg()*raketicksremaining()) > mangledmg()) then ccrCastAttack("Rake") return end
			if SCA("Shred") and ((ccrPlayerIsBehindTarget() and (ccrPHB("Omen of Clarity") or energyregen >= 15)) or ccrPHB("Berserk")) then ccrCastAttack("Shred") return end
			if SCA("Mangle") then ccrCastAttack("Mangle") return end
		end
	end
end

-- function currip()
-- 	this = math.floor(113 + 320 * ccrPoints() * CurMastery() + 0.0484 * ccrPoints() * UnitAttackPower("player") * CurMastery())*8
-- 	return this
-- end

function ripcurdmg()
	if x then x:Target() end
	for i = 1, 40 do
	   local name, _, _, _, _, _, _, caster = UnitDebuff("target", i)
	   if name == "Rip" and caster == "player" then
	      tRip = i
	   end
	end
	if select(8, UnitDebuff("target", "Rip")) == "player" then
		debuffframe:ClearLines()
		debuffframe:SetUnitDebuff("target", tRip)
	else
		return 0
	end
	if x then TargetLastTarget() end
	local text = debuffframeTextLeft2:GetText()
	local match =  string.match(text, '%d+')
	return tonumber(match)
end

function rakecurdmg(x)
	if x then x:Target() end
	for i = 1, 40 do
	   local name, _, _, _, _, _, _, caster = UnitDebuff("target", i)
	   if name == "Rake" and caster == "player" then
	      tRake = i
	   end
	end 
	if select(8, UnitDebuff("target", "Rake")) == "player" then
		debuffframe:ClearLines()
		debuffframe:SetUnitDebuff("target", tRake)
	else
		return 0
	end
	if x then TargetLastTarget() end
	local text = debuffframeTextLeft2:GetText()
	local match = string.match(text, '%d+')
	return tonumber(match)
end

function currip()
	spellframe:ClearLines()
	spellframe:SetSpellByID(1079)
	local text = spellframeTextLeft5:GetText()
	local match = string.match(text, '%d+,%d+', 267)
	local conversion = string.gsub(match, ",", "")
	return (floor(conversion/6.68))
end

function currake()
	spellframe:ClearLines()
	spellframe:SetSpellByID(1822)
	local text = spellframeTextLeft5:GetText()
	local match = string.match(text, '%d+,%d+', 50)
	local conversion = string.gsub(match, ",","")
	return(floor(conversion/5))
end

function raketicksremaining()
	local name, _, _, _, _, _, expires, caster = UnitDebuff("target", "Rake")
	if name == "Rake" and caster == "player" then
		return ceil((expires-GetTime())/3)
	else
		return 0
	end
end

function mangledmg()
	local min, max = UnitDamage("player")
	local avg = select(7, UnitDamage("player"))*390+(((min+max)/2)/2*5)
	return avg
end

function FaerieFireCheck()
	for i = 1, GetTotalObjects(TYPE_UNIT) do
		ObjectCurrent, name, expires, AgonyDuration = nil
		ObjectCurrent = GetObjectListEntry(i)
		if not ObjectCurrent:GetAura("Misery, Sorrow, and Gloom") and not ObjectCurrent:GetAura("Mark of Anguish") and not ObjectCurrent:GetAura("Dark Meditation") then
			name, _, _, count = ObjectCurrent:GetAura("Weakened Armor")
			if ObjectCurrent:GetHealth() > 0 and ObjectCurrent:GetDistance() <= 8 and ObjectCurrent:InLineOfSight() and Player:CanAttack(ObjectCurrent) and ObjectCurrent:GetCreatureInfo() ~= "Critter" and ObjectCurrent:GetCreatureInfo() ~= "Wild Pet" and (not name or count < 3) then ObjectCurrent:CastSpellByName("Faerie Fire") return end
		end
	end
end

-- math.floor(113+320*5*1.488853866311+0.0484*5*41645*1.488853866311)*8

-- math.floor(113+320*CP*1.GetMasteryEffect()+0.0484*CP*AP*1.GetMasteryEffect())*8

-- function GetNearbyTargets()
-- 	local results = {}
-- 	for index = 1, GetTotalObjects() do
-- 		local object = GetObjectListEntry(index)

-- 		if object:GetType() == TYPE_UNIT and not object:IsDead() and object:GetDistance() <= 5 and Player:CanAttack(object) then
-- 			table.insert(results, object)
-- 		end
-- 	end
-- 	return results
-- end

-- function GetNearbyUndottedTargets()
-- 	local targets = GetNearbyTargets()
-- 	local results = {}
-- 	for index, target in ipairs(targets) do
-- 		target:Target()
-- 		local name, _, _, _, _, duration, expires, caster = UnitDebuff("target", "Rake")
-- 		if not name then
-- 			table.insert(results, target)
-- 		end
-- 		if name and not caster == "player" then
-- 			table.insert(results, target)
-- 		end
-- 		if name and expires-GetTime() < 3 then
-- 			table.insert(results, target)
-- 		end
-- 		if name and currake() > rakecurdmg(target) then
-- 			table.insert(results, target)
-- 		end
-- 	end
-- 	return results
-- end

-- function feralDotNearbyTarget()
-- 	-- Dot a nearby target.
-- 	local targets = GetNearbyUndottedTargets()
-- 	local target = targets[1]
-- 	if target and Player:IsInCombat() and not Player:IsMounted() then
-- 		target:CastSpellByName("Rake")
-- 	end
-- end